using System;
using System.Drawing;
using FireStarterModeller.BO;
using FireStarterModeller.Logic;
using Habanero.Base;
using Habanero.BO;
using Habanero.BO.ClassDefinition;
using Habanero.Faces.Base;
using Habanero.Faces.Win;

namespace FireStarterModeller.UI.Relationship
{
    /// <summary>
    /// This wizard step is the first step for creating a new <see cref="DMRelationship"/>. 
    /// In this wizard step the user selects the Related Business Object
    /// from this the system will try to determine the relationshipName, related properties etc.
    /// </summary>
    public class CreateRelationshipWizardStep3 : WizardStepWin
    {
        private DMRelationshipEditorControl RelationshipEditorControl { get; set; }
        private DMRelationshipCreator RelationshipCreator { get; set; }

        public CreateRelationshipWizardStep3(DMRelationshipCreator relationshipCreator, IControlFactory controlFactory)
        {
            RelationshipCreator = relationshipCreator;
            if (relationshipCreator == null) throw new ArgumentNullException("relationshipCreator");
            if (controlFactory == null) throw new ArgumentNullException("controlFactory");
            RelationshipEditorControl = new DMRelationshipEditorControl(controlFactory);
            
            
            BorderLayoutManager layoutManager = controlFactory.CreateBorderLayoutManager(this);
            layoutManager.AddControl(RelationshipEditorControl);

            this.MinimumSize = new Size(RelationshipEditorControl.MinimumSize.Width + 30, RelationshipEditorControl.MinimumSize.Height + 50);
            this.Size = this.MinimumSize;
        }

        public override void InitialiseStep()
        {
            RelationshipEditorControl.BusinessObject = RelationshipCreator.Relationship;
        }

        public override string HeaderText
        {
            get { return "Step5: Capture Relationship details"; }
        }
    }
}